package edu.asu.sapa.lifted;


public class LiftedGoal {
	public String label=null;
	public Predicate predicate;
	
	public LiftedMathForm start=LiftedMathForm.EndRef;
	public LiftedMathForm finish=LiftedMathForm.EndRef;
	public float reward=0;
	public float penalty=Float.POSITIVE_INFINITY;
	
	public LiftedGoal(Predicate p) {
		this.predicate = p;
	}
	
	public LiftedGoal(Predicate p, float reward, float penalty) {
		this.predicate = p;
		this.reward = reward;
		this.penalty = penalty;
	}
	
	public LiftedGoal(Predicate p, LiftedMathForm deadline) {
		this.predicate = p;
		this.start = deadline;
	}
	
	public LiftedGoal(Predicate p, LiftedMathForm deadline, float reward, float penalty) {
		this.predicate = p;
		this.start = deadline;
		this.reward = reward;
		this.penalty = penalty;
	}
	
	public LiftedGoal(String label, Predicate proposition, LiftedMathForm deadline, float reward, float penalty) {
		this.label = label;
		this.predicate = proposition;
		this.start = deadline;
		this.reward = reward;
		this.penalty = penalty;
	}
	
	public LiftedGoal(String label, Predicate proposition, LiftedMathForm deadline) {
		this.label = label;
		this.predicate = proposition;
		this.start = deadline;
	}
	
	public LiftedGoal(String label, Predicate proposition) {
		this.label = label;
		this.predicate = proposition;
	}

	public String toString() {
		StringBuilder b = new StringBuilder();

		b.append("(:goal ");

		if (label != null)
			b.append(label).append(' ');
		if (start.type != 1 || start.value != Float.POSITIVE_INFINITY)
			b.append("(at ").append(start).append(' ');

		b.append(predicate);
		
		if (start.type != 1 || start.value != Float.POSITIVE_INFINITY)
			b.append(')');
		if (reward != 0 || penalty != Float.POSITIVE_INFINITY) {
			b.append(" [").append(reward);
			if (penalty != Float.POSITIVE_INFINITY) {
				b.append(", ").append(penalty).append(']');
			} else {
				b.append(']');
			}
		}
		b.append(')');

		return b.toString();
	}
}
